Namespace Entities

    Public Class UserCompetency

        Protected Sub New()

        End Sub

        Public Sub New(ByVal user As User, _
                       ByVal competency As Competency, _
                       ByVal level As KnowledgeLevel)

            Me.User = user
            Me.Competency = competency
            Me.KnoledgeLevel = level

        End Sub

        Private _user As User
        Public Overridable Property User() As User
            Get
                Return _user
            End Get
            Set(ByVal value As User)
                _user = value
            End Set
        End Property

        Private _competency As Competency
        Public Overridable Property Competency() As Competency
            Get
                Return _competency
            End Get
            Set(ByVal value As Competency)
                _competency = value
            End Set
        End Property

        Private _knoledgeLevel As KnowledgeLevel = KnoledgeLevel.None
        Public Overridable Property KnoledgeLevel() As KnowledgeLevel
            Get
                Return _knoledgeLevel
            End Get
            Set(ByVal value As KnowledgeLevel)
                _knoledgeLevel = value
            End Set
        End Property

        Public Overrides Function Equals(ByVal obj As Object) As Boolean

            If obj.GetType Is GetType(UserCompetency) Then

                Dim uc As UserCompetency = CType(obj, UserCompetency)
                If Me.User.Id = uc.User.Id And Me.Competency.Id = uc.Competency.Id Then
                    Return True
                Else
                    Return False
                End If
            End If

            Return False

        End Function

        Public Overrides Function GetHashCode() As Integer

            Return Me.Competency.Id.GetHashCode()

        End Function

    End Class

End Namespace
